#include <stdio.h>
#include <pwd.h>
#include <stddef.h>
#include <string.h>

struct passwd * all_passwd(void);
void pr_passwd_item(const struct passwd *);

int main(void)
{
    all_passwd();
}


struct passwd * all_passwd(void)
{
    struct passwd * ptr;
    setpwent();
    while ((ptr = getpwent()) != NULL)
        pr_passwd_item(ptr);
    endpwent();

    return ptr;
}

void pr_passwd_item(const struct passwd * ptr)
{

    printf("struct passwd: %s\n", ptr->pw_name);
    printf("\tpw_passwd:%s\n", ptr->pw_passwd);
    printf("\t pw_uid:%d\n", ptr->pw_uid);
    printf("\t pw_gid:%d\n", ptr->pw_gid);
    printf("\t pw_gecos:%s\n", ptr->pw_gecos);
    printf("\t pw_dir:%s\n", ptr->pw_dir);
    printf("\t pw_shell:%s\n", ptr->pw_shell);
}
